今天要來談談什麼是Cluster level ELK
Cluster 的基本工作單位是Node, 所以我今天會試著將Fluentd裝在每台Node上面
上一篇文章中有提到, DaemonSet 是一種K8s在Node上運行daemon的一種機制,
要在Node上起一個DaemonSet就必須要撰寫一個yaml file, 我這邊偷懶拿官方範例來跑
直接GG, 後來查看Issue List發現根本沒有v2.5.1
好吧只好來看看哪邊才抓的到image
最後直接在這邊找到了
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: fluentd-elasticsearch
namespace: kube-system
labels:
k8s-app: fluentd-logging
spec:
selector:
matchLabels:
name: fluentd-elasticsearch
template:
metadata:
labels:
name: fluentd-elasticsearch
spec:
tolerations:
- key: node-role.kubernetes.io/master
effect: NoSchedule
containers:
- name: fluentd-elasticsearch
image: gcr.io/fluentd-elasticsearch/fluentd:v2.4.0
resources:
limits:
memory: 200Mi
requests:
cpu: 100m
memory: 200Mi
volumeMounts:
- name: varlog
mountPath: /var/log
- name: varlibdockercontainers
mountPath: /var/lib/docker/containers
readOnly: true
terminationGracePeriodSeconds: 30
volumes:
- name: varlog
hostPath:
path: /var/log
- name: varlibdockercontainers
hostPath:
path: /var/lib/docker/containers
跑起來後要怎麼驗證Fluentd有收集到Node的Log?
我們在上面的DaemonSet有設定volumeMounts
可以看到fluentd這個Daemon收集了其他Pods的log
進入其中一台Node之後可以看到確實有個container起了個fluentd的Daemon在幫我們收集log
明天會講如何以SideCar的形式來收集log
小信豬的原始部落:
https://godleon.github.io/blog/Kubernetes/k8s-StatefulSets-Overview/
官方#DaemonSet:
https://kubernetes.io/docs/concepts/workloads/controllers/daemonset/#writing-a-daemonset-spec